<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace app\xwam\controller\sms;

/**
 * Description of SmsServerModel
 *
 * @author SoChishun
 */
class SmsServerModel {
    const TABLE='sms_server';
    public function getEnableServer($id=0){
        // 缓存增强
        $list= db(self::TABLE)->where([['status',1],['usage','=','verify_code']])->select();
        if($id<0){
            return $list;
        }
        if($id==0){
            return $list[array_rand($list)];
        }
        return $list[$id];
        
    }
    public function sendVerifyCode($mobile){
        $server=$this->getEnableServer();
        \app\common\service\SmsFactory::send($mobile);
        
    }
}
